<?php
// 本类由系统自动生成，仅供测试用途
class MessageAction extends BaseAction {
		
	/*初始化*/
	public function _initialize() {
		parent::_initialize();
              
    }
	
    public function doMess(){

		$message = M('Message');	
		$message->create();
		
		import('ORG.Net.UploadFile');

		$upload = new UploadFile();// 实例化上传类

		$upload->maxSize  = 3145728 ;// 设置附件上传大小

		$upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型

		$upload->savePath =  './Uploads/';// 设置附件上传目录

		if(!$upload->upload()) {// 上传错误提示错误信息

			$this->error($upload->getErrorMsg());

		}else{// 上传成功 获取上传文件信息

			$info =  $upload->getUploadFileInfo();

		}
		$message->filename = $info[0]['savename'];
		$message->time = time();
		$message->uid  = $_SESSION['id'];
		$lastId = $message->add();
		
		if($lastId){
			$this->redirect('Index/index');
		}else{
			$this->redirect('Index/index');
		}


	   
    }

}